use salvo::http::ParseError;
use tantivy::{query::QueryParserError, TantivyError};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
    #[error("error:`{0}`")]
    AnyHow(#[from] anyhow::Error),
    #[error("http::ParseError:`{0}`")]
    ParseError(#[from] ParseError),
    #[error("sqlx::Error:`{0}`")]
    SqlxError(#[from] sqlx::Error),
    #[error("ValidationError:`{0}`")]
    ValidationError(#[from] validator::ValidationErrors),
    #[error("io error: `{0}`")]
    IOError(#[from] std::io::Error),
    #[error("auth error: `{0}`")]
    AuthError(&'static str),
    #[error("no such resource: `{0}`")]
    NoSuchRescource(&'static str),
    #[error("bad request: `{0}`")]
    BadRequest(&'static str),
    #[error("search engine error: `{0}`")]
    SearchEngineError(#[from] TantivyError),
    #[error("Query Error: `{0}`")]
    QueryError(#[from] QueryParserError),
}